package com.team.ssm_item_lj.service.impl;

import com.team.ssm_item_lj.entity.JavaeeMember;
import com.team.ssm_item_lj.dao.JavaeeMemberDao;
import com.team.ssm_item_lj.service.JavaeeMemberService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import jakarta.annotation.Resource;

import java.util.List;

/**
 * 开发人员信息表(JavaeeMember)表服务实现类
 *
 * @author zhuxhenxin
 * @since 2024-12-05 10:44:29
 */
@Service("javaeeMemberService")
public class JavaeeMemberServiceImpl implements JavaeeMemberService {
    @Resource
    private JavaeeMemberDao javaeeMemberDao;

    /**
     * 通过ID查询单条数据
     *
     * @param mId 主键
     * @return 实例对象
     */
    @Override
    public JavaeeMember queryById(Long mId) {
        return this.javaeeMemberDao.queryById(mId);
    }

    /**
     * 分页查询
     *
     * @param javaeeMember 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<JavaeeMember> queryByPage(JavaeeMember javaeeMember, PageRequest pageRequest) {
        long total = this.javaeeMemberDao.count(javaeeMember);
        return new PageImpl<>(this.javaeeMemberDao.queryAllByLimit(javaeeMember, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param javaeeMember 实例对象
     * @return 实例对象
     */
    @Override
    public JavaeeMember insert(JavaeeMember javaeeMember) {
        this.javaeeMemberDao.insert(javaeeMember);
        return javaeeMember;
    }

    /**
     * 修改数据
     *
     * @param javaeeMember 实例对象
     * @return 实例对象
     */
    @Override
    public JavaeeMember update(JavaeeMember javaeeMember) {
        this.javaeeMemberDao.update(javaeeMember);
        return this.queryById(javaeeMember.getMId());
    }

    /**
     * 通过主键删除数据
     *
     * @param mId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long mId) {
        return this.javaeeMemberDao.deleteById(mId) > 0;
    }

    /**
     * 查询所有数据
     *
     * @return
     */
    @Override
    public List<JavaeeMember> queryAll() {
        return javaeeMemberDao.queryAll();
    }
}
